package app

import (
	"fmt"
	"net/http"

	"source"

	"google.golang.org/appengine"
	"google.golang.org/appengine/urlfetch"
)

func test(res http.ResponseWriter, req *http.Request) {
	c := appengine.NewContext(req)
	client := urlfetch.Client(c)
	resp, err := client.Get("http://www.google.com/")
	if err != nil {
		http.Error(res, err.Error(), http.StatusInternalServerError)
		return
	}
	fmt.Fprintf(res, "HTTP GET returned status %v", resp.Status)
}

func init() {
	http.HandleFunc("/", source.Xhbbs)
	http.HandleFunc("/test", test)
}
